package BandB.Tool.GPhoneManager;

import BandB.Tool.GPhoneManager.AppManager.UninstallerList;
import BandB.Tool.GPhoneManager.AppManager.Grid.UninstallerGrid;
import BandB.Tool.GPhoneManager.FileExplorer.FileExplorer;
import BandB.Tool.GPhoneManager.TaskManager.ProcessGrid;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;

/**
 * Main entry of this app
 * 
 * @author gjbie
 * 
 */
public final class GPhone extends TabActivity implements OnTabChangeListener {
	
	
	private static final String TAB_QUICKUNINSTALLER = "Quick Uninstaller";
	private static final String TAB_APP_MANAGER = "App Manager";
	private static final String TAB_TASKILLER = "Taskiller";
	private static final String TAB_FILE_MANAGER = "File Explorer";
	private static final String TAB_TOGGLES = "Toggles";
	
	

	private static final int INDEX_QUICKUNINSTALLER = 0;
	private static final int INDEX_APP_MANAGER = 1;
	private static final int INDEX_TASKILLER = 2;
	private static final int INDEX_FILE_MANAGER = 3;
	private static final int INDEX_TOGGLES = 2;
	private static final String TAG = GPhone.class.getSimpleName();
	private TabHost mTabHost;

	@Override
	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		mTabHost = getTabHost();
		
		mTabHost.addTab(mTabHost.newTabSpec(TAB_QUICKUNINSTALLER).setIndicator(
				TAB_QUICKUNINSTALLER,
				getResources().getDrawable(R.drawable.quick_uninstaller_icon))
				.setContent(new Intent(this, UninstallerGrid.class)));
		mTabHost.addTab(mTabHost.newTabSpec(TAB_APP_MANAGER).setIndicator(
				TAB_APP_MANAGER,
				getResources().getDrawable(R.drawable.app_manager_icon))
				.setContent(new Intent(this, UninstallerList.class)));
		mTabHost.addTab(mTabHost.newTabSpec(TAB_TASKILLER).setIndicator(
				TAB_TASKILLER,
				getResources().getDrawable(R.drawable.taskiller_icon))
				.setContent(new Intent(this, ProcessGrid.class)));
		mTabHost.addTab(mTabHost.newTabSpec(TAB_FILE_MANAGER).setIndicator(
				TAB_FILE_MANAGER,
				getResources().getDrawable(R.drawable.file_explorer_icon))
				.setContent(new Intent(this, FileExplorer.class)));
		mTabHost.addTab(mTabHost.newTabSpec(TAB_TOGGLES).setIndicator(
				TAB_TOGGLES,
				getResources().getDrawable(R.drawable.toggler_iocn))
				.setContent(new Intent(this, Toggles.class)));
		
		
		mTabHost.setOnTabChangedListener(this);

		mTabHost.setCurrentTab(INDEX_QUICKUNINSTALLER);
		
		/*if (null != getIntent()) {
			mTabHost.setCurrentTab(INDEX_APP_MANAGER);
		} else {
			final Intent intent = new Intent(this, UninstallerList.class);
//			setCurrentTab(intent);
		}*/
	}

	/**
	 * Set which view to be displayed in this tabActivity
	 * 
	 * @param intent
	 *            {@link Intent} object
	 */
	/*private void setCurrentTab(final Intent intent) {
		final String componentName = intent.getComponent().getClassName();
		if (getClass().getName().equals(componentName)) {
			mTabHost.setCurrentTab(INDEX_FILE_MANAGER);
		} else if (UninstallerList.class.toString().equals(componentName)) {
			mTabHost.setCurrentTab(INDEX_APP_MANAGER);
		} else {
			getTabHost().setCurrentTab(INDEX_TASK_MANAGER);
		}
	}*/

	@Override
	public void onTabChanged(final String tabId) {
		// TODO Auto-generated method stub
		Log.i(TAG, "TabChanged tabId:" + tabId);
	}
}